package com.guet.imageAndVideo.controller;

import com.guet.common.entity.PageDataVO;
import com.guet.common.entity.PageVO;
import com.guet.common.response.ResultCodeEnum;
import com.guet.common.response.ResultVO;
import com.guet.imageAndVideo.beans.entity.Image;
import com.guet.imageAndVideo.service.IImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Li
 * @create 2022-12-16-21:47
 */
@RestController
@RequestMapping("/image")
public class ImageController {

    @Autowired
    IImageService imageService;



    @ResponseBody
    @RequestMapping("/select")
    public ResultVO<PageDataVO<Image>> select(@RequestParam Integer userId, PageVO pageVO){

        PageDataVO<Image> pageDataVO = imageService.select(userId, pageVO);

        return new ResultVO<>(ResultCodeEnum.SUCCESS, pageDataVO);

    }

    @RequestMapping("/deletes")
    public ResultVO deletes(@RequestParam Integer userId, @RequestParam List<Integer> imageIds){

        imageService.delete(userId, imageIds);

        return new ResultVO(ResultCodeEnum.SUCCESS);
    }

}
